import axios from 'axios'

export default {
  async getToolbox() {
    const url = 'https://wb-service.arthub.qq.com/blade/blade/openapi/v1/core/get-child-node-brief-in-range'

    const params = {
      parent_id: 99120641221067,
      grouping: '',
      offset: 0,
      count: 500,
      order: { meta: 'name', type: 'asc' },
      meta: 'name',
      type: 'asc',
      client_version: 'v1.2.0',
    }

    try {
      const res = await axios.post(url, params, {
        headers: {
          'Content-Type': 'application/json',
          // 这里写死 Cookie
          Cookie: 'arthub_account_ticket=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X25hbWUiOiJiazdicTJweXNqcHlzYnF4cTVxMzZhbWE2dG5qN3JuZ3FjNiIsInVuaXF1ZV9pZCI6OTkxMjA2NDE1NzY1OTQsInRpbWUiOjE3NTg3ODMwMzIwMjAsInRpbWVvdXQiOjI1OTIwMDAwMDAsInRlcm1pbmFsX3R5cGUiOiJkZXNrdG9wV2luIiwiYnVzaW5lc3NfdHlwZSI6ImxpZ2h0Ym94QmxhZGUiLCJhdWQiOiJBY2NvdW50U2VydmljZSIsImV4cCI6MTc2MTM3NTAzMiwiaWF0IjoxNzU4NzgzMDMyfQ.EHFMU6AOgvS4LF6BsXfGNq45cCxRC29PL9EhrqjDNEI; accountName=bk7bq2pysjpysbqxq5q36ama6tnj7rngqc6; mailAddress=xuchuanlin%40beyondsoft.com',
        },
      })
      // console.log('✅ 请求成功:', res.data)
      return res.data
    } catch (err) {
      console.error('❌ 请求失败:', err)
      return err
    }
  },

  // 获取用户组
  async getUserGroup() {
    const url = 'https://wb-service.arthub.qq.com/blade/blade/openapi/v1/core/user_group'

    const params = {

    }

    try {
      const res = await axios.get(url, {
        params,
        headers: {
          'Content-Type': 'application/json',
          // 这里写死 Cookie
          Cookie: 'arthub_account_ticket=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X25hbWUiOiJiazdicTJweXNqcHlzYnF4cTVxMzZhbWE2dG5qN3JuZ3FjNiIsInVuaXF1ZV9pZCI6OTkxMjA2NDE1NzY1OTQsInRpbWUiOjE3NTg3ODMwMzIwMjAsInRpbWVvdXQiOjI1OTIwMDAwMDAsInRlcm1pbmFsX3R5cGUiOiJkZXNrdG9wV2luIiwiYnVzaW5lc3NfdHlwZSI6ImxpZ2h0Ym94QmxhZGUiLCJhdWQiOiJBY2NvdW50U2VydmljZSIsImV4cCI6MTc2MTM3NTAzMiwiaWF0IjoxNzU4NzgzMDMyfQ.EHFMU6AOgvS4LF6BsXfGNq45cCxRC29PL9EhrqjDNEI; accountName=bk7bq2pysjpysbqxq5q36ama6tnj7rngqc6; mailAddress=xuchuanlin%40beyondsoft.com',
        },
      })
      // console.log('✅ 请求成功:', res.data)
      return res.data
    } catch (err) {
      console.error('❌ 请求失败:', err)
      return err
    }
  }
}